package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;

import com.qidianit.mes.pojo.pro.WorkflowProcess;
import com.qidianit.mes.pro.service.WorkflowProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/workflowProcess")
@CrossOrigin
public class WorkflowProcessController {
    @Autowired
    private WorkflowProcessService workflowProcessService;
    @GetMapping("/page")
    public Result<PageInfo<WorkflowProcess>>
    list(Long workflowId, @RequestParam(defaultValue = "1")int page,
         @RequestParam(defaultValue = "10")int size){
        return workflowProcessService.selectList(workflowId,page,size);
    }

    @PostMapping("add")
    public Result<WorkflowProcess> saveWorkflowProcess(@RequestBody  WorkflowProcess workflowProcess){

        return workflowProcessService.saveWorkflowProcess(workflowProcess);
    }

    @GetMapping("/{id}")
    public Result<WorkflowProcess> selectById(@PathVariable("id") Long id){
        return workflowProcessService.selectById(id);
    }

    @PutMapping("/update")
    public Result<WorkflowProcess> updateById(@RequestBody WorkflowProcess workflowProcess){

        return workflowProcessService.updateById(workflowProcess);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable("id") Long id){
        return workflowProcessService.deleteById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete( Long[] id){
        return workflowProcessService.batchDelete(id);
    }
}
